<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>

    // 异步操作 => 未来改变状态
    var p = new Promise(function (resolve, reject) {
        setTimeout(function () {
            resolve(1);
            // reject(2);
        }, 2000);
    })

    console.log(p);


    // p => p.then() 
    //      p1.catch()

    // 异步(状态改变) => p => p1  

    p.then(function (res) {
        console.log("fulfilled", res);
    }).catch(function (err) {
        console.log("reject", err);
    })

</script>

</html>